package cms.manage.template.impl;

import java.util.Map;

import cms.bean.template.CustomHTML;
import cms.bean.template.Forum;
import cms.bean.template.ForumCustomForumRelatedCustomHTML;
import cms.utils.JsonUtils;

import org.springframework.stereotype.Component;

/**
 * 自定义版块 -- 模板方法实现
 *
 */
@Component
public class CustomForumTemplateManage {
	
	/**
	 * 自定义HTML -- 实体对象
	 * @param forum
	 */
	public CustomHTML customHTMLEntityBean(Forum forum, Map<String,Object> parameter, Map<String,Object> runtimeParameter){
		String formValueJSON = forum.getFormValue();//表单值
		if(formValueJSON != null && !"".equals(formValueJSON)){
			ForumCustomForumRelatedCustomHTML forumCustomForumRelatedCustomHTML = JsonUtils.toObject(formValueJSON, ForumCustomForumRelatedCustomHTML.class);
			if(forumCustomForumRelatedCustomHTML != null){
				CustomHTML customHTML = new CustomHTML();
				customHTML.setForumTitle(forum.getName());
				customHTML.setContent(forumCustomForumRelatedCustomHTML.getHtml_content());
				return customHTML;
			}
		}
		return null;
	}
}
